import { http } from "@/utils/http";
// 转换字符串，undefined,null等转化为""
export function parseStrEmpty(str) {
  if (!str || str == "undefined" || str == "null") {
    return "";
  }
  return str;
}
// 查询字典数据列表
export function listData(query) {
  return http.request("get", "/system/dict/data/list", { params: query });
}

// 查询字典数据详细
export function getData(dictCode) {
  return http.request("get", "/system/dict/data/" + parseStrEmpty(dictCode));
}

// 根据字典类型查询字典数据信息
export function getDicts(dictType) {
  return http.request("get", "/system/dict/data/type/" + dictType);
}

// 新增字典数据
export function addData(data) {
  return http.request("post", "/system/dict/data", { data });
}

// 修改字典数据
export function updateData(data) {
  return http.request("put", "/system/dict/data", { data });
}

// 删除字典数据
export function delData(dictCode) {
  return http.request("delete", "/system/dict/data/" + dictCode);
}
